<!DOCTYPE html>
<html>
<head>
    <title>二维码管理</title>
    <meta name="viewport" content="width=device-width,height=device-height, initial-scale=1, maximum-scale=1, user-scalable=no">
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="/stylesheets/bootstrap.min.css">
    <!-- 可选的Bootstrap主题文件（一般不用引入） -->
    <!--<link rel="stylesheet" href="/stylesheets/bootstrap-theme.min.css">-->
    <link href="/stylesheets/bootstrap-responsive.css" rel="stylesheet" media="screen">
    <link rel="stylesheet" type="text/css" href="/stylesheets/style.css">
    <script src="../javascripts/lib/jquery.min.js"></script>
    <script src="../javascripts/lib/bootstrap.min.js"></script>
    <script type="text/javascript" src="../javascripts/bootstrap-paginator.min.js"></script>
    <script type="text/javascript" src="../javascripts/lib/qrcode.js"></script>
    <script type="text/javascript" src="../javascripts/qrcodeM.js"></script>
</head>
<body style="margin:15px;padding-bottom: 0px;margin-top: 10px;">
<div id="lert"></div>
<tbody>
<legend>二维码管理</legend>
<div style="margin-bottom:15px;">
    <a href="/createQRcode?err=0" style="text-decoration: none">
        <input type="button" style="color:#000000;width:55px;height:30px;" value="新增"/>
    </a>
    <!--<input type="button" style="width:55px;height:30px;" name="checkAll" value="全选" onclick="changeAll()" />-->
    <!--<input type="button" style="width:55px;height:30px;" value="反选" onclick="fanxuan();change()"/>-->
    <!--<input type="button" style="width:55px;height:30px;" value="打印" onclick="Allprint()"/>-->
</div>
<table class="table table-bordered table-striped table-condensed" style="margin-top:1px">
    <thead style="background-color:beige">
        <td class="td_sim" style="text-align: center;"> <b>二维码名称</b>
        </td>
        <td class="operators" style="text-align: center;"><b>操作</b>
        </td>
    </thead>
    <tbody>
    <%for(var i=0;i<datas.codes.length;i++){%>
    <tr style="height:40px">
        <td  style="padding-left: 10%">
            <!--<label class="checkbox inline"></label>-->
            <!--<input type="text" name="son" value="<%=datas.codes[i].codeid %>"/>-->
            <%=datas.codes[i].codename%>
        </td>
        <td class="operators" style="text-align: center;">
            <button style="width:105px;height:30px;margin-right:5px;" name="<%=datas.codes[i].codename%>" class="operation_btn" id="<%=datas.codes[i].codeid%>">打印预览</button>
           <!-- <input style="width:55px;height:30px;margin-right:5px;" type="button" class="print" value="打印" name="<%=datas.codes[i].codeid%>"/>-->
            <a href="/removecode?codeid=<%=datas.codes[i].codeid %>" style="color:#000000;text-decoration: none" onclick="return confirm('确定删除该二维码?')">
                <input type="button" style="width:55px;height:30px;" value="删除"/>
            </a>
        </td>
    </tr>
    <%}%>
    </tbody>
</table>

<div class="span12">
    <ul class="pagination" style="margin-top: 0px;">
        <% if(parseInt(datas.page.current_page) == 1){ %>
        <li><a href="/qrcode?page=<%= datas.page.current_page %>">&laquo;</a></li>
        <% }else{ %>
        <li><a href="/qrcode?page=<%= datas.page.current_page - 1 %>">&laquo;</a></li>
        <% } %>

        <% for(var i = 1;i <= datas.page.total_page;i++){ %>
        <% j = i %>
        <% if(i == datas.page.current_page){ %>
        <li class="active"><a href="/qrcode?page=<%= i %>"><%= i %></a></li>
        <% }else{ %>
        <li><a href="/qrcode?page=<%= i %>"><%= i %></a></li>
        <% } %>
        <% } %>

        <% if(datas.page.current_page == datas.page.total_page) { %>
        <li><a href="/qrcode?page=<%= datas.page.current_page %>">&raquo;</a></li>
        <% }else{ %>
        <li><a href="/qrcode?page=<%= parseInt(datas.page.current_page) + 1 %>">&raquo;</a></li>
        <% } %>
    </ul>
</div>
<div class="span12">
    <div id="page1" style="margin-bottom:0"></div>
</div>
<!--<div id='xcode' style="margin-left:35%;width:400px; height:400px; margin-top:15px;display:none"></div>-->

<!--startprint-->
<div id="qrcode" style="margin-left:10%;width:400px; height:400px; margin-top:15px;display:none"></div>
<!--endprint-->
<!--++++++++++-->
<div id='Allcode' style="margin-left:10%;margin-bottom:10%;display:none"></div>
<!--========-->
</body>



<script type="text/javascript">

    $('.operation_btn').click(function() {
        //$("#qrcode").empty();
        var qrcode = new QRCode(document.getElementById("qrcode"), {
            width : 400,
            height : 400
        });
        var codeid = this.id;
        var codename = this.name;
        var html="<br><h3 style='text-align: center'>"+codename+"</h3>";
        $('#qrcode').append(html);
        var texts="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx631f54c7933d782f&redirect_uri=http://117.78.6.144/wcpay/socket&response_type=code&scope=snsapi_userinfo&state="+codeid+"#wechat_redirect";
        qrcode.makeCode(texts);
        $("#qrcode").show();
        setTimeout(function(){Print();},100);
    });
    function Print() {
        bdhtml = window.document.body.innerHTML;
        sprnstr = "<!--startprint-->";
        eprnstr = "<!--endprint-->";
        prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
        prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
        window.document.body.innerHTML = prnhtml;
        window.print();
        window.location.reload();
    }

</script>
</html>